package com.teemor.tim.model.user;

import com.teemor.tim.processor.state.UserState;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @ename zhoulk
 * @cname 周李科
 * @date 2020/12/14 10:08
 */
@Data
@NoArgsConstructor
public class UserStateModel extends UserState implements Serializable {
    private static final long serialVersionUID = -5470769180641032909L;

    /**
     * 会话中的用户列表
     */
    private List<UserStateModel> sessionUsers;

    public  UserStateModel(UserState userState) {
        super(userState.getUserId(), userState.getState(), userState.getUserType());
        sessionUsers = new ArrayList<>();
    }

    public UserStateModel(String userId, String state) {
        super(userId, state, null);
        sessionUsers = new ArrayList<>();
    }

    public UserStateModel(String userId, String state, String userType) {
        super(userId, state, userType);
        sessionUsers = new ArrayList<>();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserStateModel userStateModel = (UserStateModel) o;
        return this.getUserId().equals(userStateModel.getUserId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(this.getUserId());
    }
}
